package com.woniuxy.pxxt.service.impl;


import com.woniuxy.pxxt.common.result.Result;
import com.woniuxy.pxxt.dao.DepartmentDao;
import com.woniuxy.pxxt.dto.SelectMenuDto;
import com.woniuxy.pxxt.dto.department.DepartmentDtoSkc;
import com.woniuxy.pxxt.entity.Department;
import com.woniuxy.pxxt.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 部门表(Department)表服务实现类
 *
 * @author makejava
 * @since 2022-03-07 16:28:52
 */
@Service
public class DepartmentServiceImpl implements DepartmentService {
    @Autowired
    private DepartmentDao departmentDao;
    @Override
    public Result findAllManager() {
        return Result.ok(departmentDao.findAllManager());
    }

    @Override
    public Result findAllDepartment() {
        List<Department> departments = departmentDao.findAllDepartment();
        ArrayList<DepartmentDtoSkc> departmentDtoSkcs = new ArrayList<>();
        departments.forEach(item ->{
            departmentDtoSkcs.add(new DepartmentDtoSkc(item.getId(),item.getDepartmentName()));
        });
        return Result.ok(departmentDtoSkcs);
    }
}
